<template>
	<view>
		<!-- <uni-nav-bar left-text="所有订单" :background-color="background" :border-bottom="true" height="400"></uni-nav-bar> -->
		<uni-section title="所有订单" type="line" padding>
			<view class="uni-padding-wrap uni-common-mt">
				<uni-segmented-control :current="current" :values="items" :style-type="styleType"
					:active-color="activeColor" @clickItem="onClickItem" />
			</view>
		</uni-section>
		
		<!-- 订单列表 -->
		<view>
			<view v-if="current === 0">
				<view class="order-list" v-for="(item, index) in order_list1" :key="index" >
					<uni-card v-if="true" title="订单详情" :sub-title="item.raddress" :extra="item.rcontent" :thumbnail="order_picture" @click="enterOrder(item)">
						<text>{{item.detail}}</text>
					</uni-card>
				</view>
			</view>
			<view v-if="current === 1">
				<view class="order-list" v-for="item in order_list2" :key="item.oid" >
					<uni-card v-if="item.state===1"  title="订单详情" :sub-title="item.oid" :extra="items[item.state]" :thumbnail="order_picture" @click="enterOrder(item)">
						<text>{{item.detail}}</text>
					</uni-card>
				</view>
			</view>
			<view v-if="current === 2">
				<view class="order-list" v-for="item in order_list3" :key="item.oid" >
					<uni-card v-if="item.state===2" title="订单详情" :sub-title="item.oid" :extra="items[item.state]" :thumbnail="order_picture" @click="enterOrder(item)">
						<text>{{item.detail}}</text>
					</uni-card>
				</view>
			</view>
		</view>
		
		<tabBar :pagePath="'/pages/normal/mypublish'"></tabBar>
		
	</view>
</template>

<script>
	export default {
		data(){
			return {
				background: "#76EEC6",
				currentTab:0,
				items: ['未完成', '正在进行', '已完成'],
				current: 0,
				activeColor: '#007aff',
				styleType: 'button',
				order_picture: "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png",
				order_list1: [
					
				],
				order_list2: [],
				order_list3: []
			}	
		},
		methods: {
			onClickItem(e) {
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
				}
			},
			enterOrder(order) {
				console.log("跳转到订单详情页")
				uni.navigateTo({
					url:"detail?order=" + JSON.stringify(order)
				});
			}
		},
		onReachBottom() {
			console.log("触底")
		},
		onShow(){
			uni.request({
				url:"http://localhost:8081/repair/check_repair1?uid=" + getApp().globalData.id,
				method:"GET"
			}).then(res=>{
				console.log(res);
				if(res[1].data.code==200){
					this.order_list1=res[1].data.data;
					console.log(this.order_list1[0]);
					// order_list2=res.data[1],
					// order_list3=res.data.list[2]
				}
				else{
					uni.showToast({
						icon:"error",
						title:"加载出错"
					})
				}
			})
		}
	}
</script>

<style>
	.uni-padding-wrap {
		width: 710rpx;
		padding: 0px 0px;
	}
	.uni-common-mt {
		margin-top: 0px;
	}
	.content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: center;
		align-items: center;
		height: 150px;
		text-align: center;
	}
	.content-text {
		font-size: 14px;
		color: #666;
	}
	.order-list {
		
	}
	.order-item {
		
	}
</style>